package cn.lkx.statistics.controller;


import cn.lkx.commonutils.R;
import cn.lkx.statistics.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author lkx
 * @since 2022-05-14
 */
@RestController
@RequestMapping("/servicestatistics/statistics")
@CrossOrigin
public class StatisticsDailyController {
    @Autowired
    StatisticsDailyService dailyService;

    //生成数据，存入数据库统计表
    @PostMapping("createStatisticsByDay/{day}")
    public R createStatisticsByDate(@PathVariable String day){
        dailyService.createStatisticsByDay(day);
        return R.ok();
    }

    //根据类型 日期范围的 选择获取统计数据
    @GetMapping("showChart/{begin}/{end}/{type}")
    public R showChart(@PathVariable String begin,@PathVariable String end,@PathVariable String type){
        Map<String,Object> map = dailyService.getChartData(begin,end,type);
        return R.ok().data(map);
    }
}

